﻿<phone:PhoneApplicationPage xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"  
    x:Class="QWeiBoN.UserControler.WeiboDetailPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:es="clr-namespace:Microsoft.Expression.Shapes;assembly=Microsoft.Expression.Drawing"
    xmlns:converter="clr-namespace:QWeiBoN.Converter"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <converter:TextImageSourceConverter x:Key="TextImageSourceConverter"/>
        <converter:StatusNameAndImageConverter x:Key="StatusNameAndImageConverter"/>
        <converter:ConvertWeiboDetailContent x:Key="ConvertWeiboDetailContent" />
        <converter:StatusNameAndTextIsShow x:Key="StatusNameAndTextIsShow"/>
        <converter:VipImageShow x:Key="VipImageShow" />
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot 包含根网格，其他所有页面内容都位于根网格中-->
    <Grid x:Name="LayoutRoot" HorizontalAlignment="Left">

        <controls:Panorama x:Name="DetailPanorama" SelectionChanged="Panorama_SelectionChanged">
            <controls:Panorama.Title>
                <StackPanel Orientation="Vertical" x:Name="DetailUserInfo" Margin="10,90,0,0" Tap="DetailUserInfo_Tap">
                    <StackPanel Orientation="Horizontal">
                        <Image x:Name="DetailUserHead" Stretch="Fill" Width="80" Height="80" Source="/Resources/noHead.png" /> 
                        <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                <TextBlock x:Name="DetailUserNick" Style="{Binding DetailUserNickStyle}" Text="张磊" FontSize="30" />
                                <Image x:Name="DetailUserVip" Source="/Resources/v.png" Stretch="Fill" Width="24" Height="24" Visibility="Collapsed" />
                            </StackPanel>
                            <TextBlock x:Name="DetailUserName" Text="张张" FontSize="20" Style="{StaticResource DetailUserName}"/>
                        </StackPanel>
                    </StackPanel>
                    <!-- 进度条 -->
                    <toolkit:PerformanceProgressBar x:Name="DetailProgressBar" Margin="0,10,0,0" Width="400" Grid.Row="0" HorizontalAlignment="Center" Style="{Binding PerformanceProgressBarStyle}" />
                </StackPanel>
            </controls:Panorama.Title>

            <!--Panorama 项目一-->
            <controls:PanoramaItem>
                <controls:PanoramaItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="微博详情" FontSize="50" />
                        </StackPanel>
                    </DataTemplate>
                </controls:PanoramaItem.HeaderTemplate>
                <Grid x:Name="DetailItemGrid">
                    <StackPanel Margin="10,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Vertical">
                        <TextBlock FontSize="21" Margin="-10,5,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Nick}" />
                        <RichTextBox Padding="0" FontSize="21" Margin="-10,5,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Tag="{Binding Id}" CacheMode="BitmapCache">
                            <i:Interaction.Behaviors>
                                <converter:ConvertWeiboDetailContent Content="{Binding Origtext}"></converter:ConvertWeiboDetailContent>
                            </i:Interaction.Behaviors>
                        </RichTextBox>
                        <Image Name="MyTextImg" Margin="0,5,0,0" Source="{Binding Image, Converter={StaticResource TextImageSourceConverter}}" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top" Tag="{Binding Image, Converter={StaticResource TextImageSourceConverter}}" />
                        <Grid Visibility="{Binding Source, Converter={StaticResource StatusNameAndTextIsShow}}" Margin="0,5,0,0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="8" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <es:RegularPolygon Style="{StaticResource ParentTextBackgroundArrow}">
                                <es:RegularPolygon.RenderTransform>
                                    <CompositeTransform SkewX="37"/>
                                </es:RegularPolygon.RenderTransform>
                            </es:RegularPolygon>
                            <Grid Grid.Row="1" Style="{StaticResource TweetListParentTextBg}">
                                <StackPanel Margin="5,5,0,10" HorizontalAlignment="Left" Orientation="Vertical">
                                    <RichTextBox Padding="0" FontSize="21" Margin="-10,5,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" CacheMode="BitmapCache">
                                        <i:Interaction.Behaviors>
                                            <converter:ConvertWeiboDetailContent Content="{Binding Source.Origtext}"></converter:ConvertWeiboDetailContent>
                                        </i:Interaction.Behaviors>
                                    </RichTextBox>
                                    <Image Name="SourceImg" Margin="0,5,0,0" Source="{Binding Source, Converter={StaticResource StatusNameAndImageConverter}}" Tag="{Binding Source, Converter={StaticResource StatusNameAndImageConverter}}" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top" />
                                </StackPanel>
                            </Grid>
                        </Grid>
                    </StackPanel>
                </Grid>
            </controls:PanoramaItem>

            <!--Panorama 项目二-->
            <controls:PanoramaItem>
                <controls:PanoramaItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="微博评论" FontSize="50" />
                        </StackPanel>
                    </DataTemplate>
                </controls:PanoramaItem.HeaderTemplate>
                <Grid>
                    <ListBox x:Name="DetailCommentsList" VerticalAlignment="Top" HorizontalAlignment="Left">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0,10,0,0" VerticalAlignment="Top">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="60" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
                                        <Image Name="UserHeader" Margin="0,5,0,0"  Stretch="None" Source="{Binding Head}"  HorizontalAlignment="Left" VerticalAlignment="Top" Tag="{Binding Name}" />
                                    </StackPanel>
                                    <StackPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left">
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top">
                                            <TextBlock TextWrapping="Wrap" Text="{Binding Nick}" Width="340" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0" />
                                            <Image Source="/Resources/v.png" Stretch="Fill" Width="24" Height="24" Visibility="{Binding Isvip, Converter={StaticResource VipImageShow}}" />
                                        </StackPanel>
                                        <!--
                                <TextBlock TextWrapping="Wrap" Text="{Binding Origtext}" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0" Margin="0,5,0,0"/>
                                -->
                                        <RichTextBox Padding="0" FontSize="21" Margin="0,5,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Tag="{Binding Id}" CacheMode="BitmapCache">
                                            <i:Interaction.Behaviors>
                                                <converter:ConvertWeiboContentBehavior Content="{Binding Origtext}"></converter:ConvertWeiboContentBehavior>
                                            </i:Interaction.Behaviors>
                                        </RichTextBox>
                                    </StackPanel>
                                    <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,10,10">
                                        <TextBlock TextWrapping="Wrap" FontSize="15"  VerticalAlignment="Top" Width="340" Text="{Binding From}"/>
                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                        <!-- 手势 -->
                        <toolkit:GestureService.GestureListener>
                            <toolkit:GestureListener GestureCompleted="GestureListener_GestureCompleted" DragStarted="GestureListener_DragStarted"/>
                        </toolkit:GestureService.GestureListener>
                    </ListBox>
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>

    <!--基于 Panorama 的应用程序不应显示 ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Opacity="0.9">
            <shell:ApplicationBarIconButton x:Name="RePostBarBtn" Click="RePostBarBtn_Click" IconUri="/Resources/icon/refresh.png" Text="转播" />
            <shell:ApplicationBarIconButton x:Name="DetailCommentBarBtn" Click="DetailCommentBarBtn_Click" IconUri="/Resources/icon/refresh.png" Text="评论" />
            <shell:ApplicationBarIconButton x:Name="DetailBackBarBtn" Click="DetailBackBarBtn_Click" IconUri="/Resources/icon/refresh.png" Text="返回" />
            <shell:ApplicationBarIconButton x:Name="DetailHomeBarBtn" Click="DetailHomeBarBtn_Click" IconUri="/Resources/icon/refresh.png" Text="主页" />
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="DetailCollectBarBtn" Click="DetailCollectBarBtn_Click" Text="收藏" />
                <shell:ApplicationBarMenuItem x:Name="DetailShareBarBtn" Text="分享" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>